package cn.wolfcode.crm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.wolfcode.crm.domain.Permission;
import cn.wolfcode.crm.mapper.PermissionMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.IPermissionService;
@Service
public class PermissionServiceImpl implements IPermissionService{

	@Autowired
	private PermissionMapper permissionMapper;

	@Override
	public void saveOrUpdate(Permission entity) {
		if (entity.getId() == null) {
			permissionMapper.insert(entity);
		}else {
			permissionMapper.update(entity);
		}
		
	}

	@Override
	public Permission get(Long id) {
		return permissionMapper.selectById(id);
	}

	@Override
	public PageInfo<Permission> list(QueryObject qo) { 
		PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
		List<Permission> list = permissionMapper.selectAll(qo);
		return new PageInfo<>(list);
	}

	@Override
	public List<Permission> listNotPage(QueryObject qo) {
		List<Permission> list = permissionMapper.selectAll(qo);
		return list;
	}

}
